package com.hsteach.web.controller.activity;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.hsteach.common.core.controller.BaseController;
import com.hsteach.common.core.domain.AjaxResult;
import com.hsteach.common.core.page.TableDataInfo;
import com.hsteach.common.utils.poi.ExcelUtil;
import com.hsteach.service.activity.ActivityFilesService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hsteach.dao.domain.activity.ActivityFiles;

/**
 * 活动附件Controller
 * 弃用
 * @author fanxquer
 * @date 2023-07-11
 */
@RestController
@RequestMapping("/files/files")
@Deprecated
public class ActivityFilesController extends BaseController
{
    @Autowired
    private ActivityFilesService activityFilesService;

    /**
     * 查询活动附件列表
     */
    @PreAuthorize("@ss.hasPermi('files:files:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivityFiles activityFiles)
    {
        startPage();
        List<ActivityFiles> list = activityFilesService.selectActivityFilesList(activityFiles);
        return getDataTable(list);
    }

    /**
     * 导出活动附件列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivityFiles activityFiles)
    {
        List<ActivityFiles> list = activityFilesService.selectActivityFilesList(activityFiles);
        ExcelUtil<ActivityFiles> util = new ExcelUtil<ActivityFiles>(ActivityFiles.class);
        util.exportExcel(response, list, "活动附件数据");
    }

    /**
     * 获取活动附件详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(activityFilesService.selectActivityFilesById(id));
    }

    /**
     * 新增活动附件
     */
    @PreAuthorize("@ss.hasPermi('files:files:add')")
    @PostMapping
    public AjaxResult add(@RequestBody ActivityFiles activityFiles)
    {
        return toAjax(activityFilesService.insertActivityFiles(activityFiles));
    }

    /**
     * 修改活动附件
     */
    @PreAuthorize("@ss.hasPermi('files:files:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody ActivityFiles activityFiles)
    {
        return toAjax(activityFilesService.updateActivityFiles(activityFiles));
    }

    /**
     * 删除活动附件
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(activityFilesService.deleteActivityFilesByIds(ids));
    }
}
